package com.humanmonth.util.effect
{
	import flash.events.MouseEvent;
	
	import mx.core.UIComponent;
	import mx.effects.Glow;
	import mx.effects.Sequence;
	
	public class GlowUntilClickEffect
	{
		private var alphaSmall:Number=0.3;
		private var alphaBig:Number=0.5;
		private var blurSmall:Number=0;
		private var blurBig:Number=25;
		private var sequence:Sequence=new Sequence();
		private var color:uint=0x3399FF;
		private var duration:int=300;
		private var obj:UIComponent;
		public function GlowUntilClickEffect(obj:UIComponent)
		{
			this.obj=obj;
			var glowBig:Glow=new Glow();
			glowBig.color=color;
			glowBig.alphaFrom=this.alphaBig;
			glowBig.alphaTo=this.alphaSmall;
			glowBig.blurXFrom=this.blurSmall;
			glowBig.blurXTo=this.blurBig;
			glowBig.blurYFrom=this.blurSmall;
			glowBig.blurYTo=this.blurBig;
			glowBig.duration=duration;
			var glowSmall:Glow=new Glow();
			glowSmall.color=color;
			glowSmall.alphaFrom=this.alphaSmall;
			glowSmall.alphaTo=this.alphaBig;
			glowSmall.blurXFrom=this.blurBig;
			glowSmall.blurXTo=this.blurSmall;
			glowSmall.blurYFrom=this.blurBig;
			glowSmall.blurXTo=this.blurSmall;
			glowSmall.duration=duration;
			this.obj.addEventListener(MouseEvent.MOUSE_DOWN,onClick);
			this.sequence.addChild(glowBig);
			this.sequence.addChild(glowSmall);
			this.sequence.target=obj;
			this.sequence.repeatCount=1000;
			this.sequence.play();
		}
		
		private function onClick(event:MouseEvent):void{
			this.sequence.end();
		}

	}
}